package com.alan.search.controller;

import com.alan.search.entity.OrderBO;
import com.alan.search.entity.OrderForm;
import com.alan.search.entity.OrderSearchDTO;
import com.alan.search.service.OrderService;
import com.alan.search.vo.EsPage;
import com.alan.search.vo.OrderVO;
import com.alan.search.vo.ResultVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;

/**
 * 订单管理
 *
 * @author shiml
 * @date 2021/12/3 11:59 上午
 */
@Api(tags = "订单管理接口")
@RestController
@RequiredArgsConstructor
public class OrderController {

    private final OrderService orderService;

    @PostMapping(value = "/orders/search")
    @ApiOperation(value = "订单搜索")
    public ResultVO<EsPage<OrderVO>> pageOrder(@RequestBody OrderSearchDTO dto) {
        EsPage<OrderVO> page = orderService.pageOrder(dto);
        return ResultVO.ok(page);
    }

    @GetMapping(value = "/orders/{orderNo}")
    @ApiOperation(value = "订单详情")
    public ResultVO<OrderVO> getOrder(@PathVariable Long orderNo) {
        OrderVO result = orderService.getOrder(orderNo);
        return ResultVO.ok(result);
    }

    @PostMapping(value = "/orders")
    @ApiOperation(value = "订单新增")
    @ApiIgnore
    public ResultVO<Object> createOrder(@RequestBody OrderForm form) {
        // todo
        return ResultVO.ok("开发中");
    }

    @PutMapping(value = "/orders/{orderId}")
    @ApiOperation(value = "订单全量修改")
    @ApiIgnore
    public ResultVO<Object> updateOrder(@PathVariable Long orderNo) {
        // todo
        return ResultVO.ok("开发中");
    }

    @PatchMapping(value = "/orders/{orderId}")
    @ApiOperation(value = "订单局部修改")
    @ApiIgnore
    public ResultVO<Object> updatePartOrder(@PathVariable Long orderNo) {
        // todo
        return ResultVO.ok("开发中");
    }

    @DeleteMapping(value = "/orders/{orderId}")
    @ApiOperation(value = "订单删除")
    @ApiIgnore
    public ResultVO<Object> deleteOrder(@PathVariable Long orderNo) {
        // todo
        return ResultVO.ok("开发中");
    }

}
